package at.fhooe.pandora.utils;

import java.util.ArrayList;

import at.fhooe.engine.pandora.Game;
import at.fhooe.engine.scenegraph.SceneNode;
import at.fhooe.engine.visuals.TextVisual;
import at.fhooe.pandora.entities.ResourceEntity;

/**
 * Holds the amount of all available resources
 */
public class ResourceCounter
{
	private ArrayList<Integer> m_resources;
	private TextVisual m_text;
	private SceneNode node;
	
	public ResourceCounter()
	{
		m_resources = new ArrayList<Integer>();
		m_resources.add(0);
		m_resources.add(0);
		m_resources.add(0);
		
		int height = Game.getInstance().getGraphicsSystem().getHeight();
		
		node = Game.getInstance().getSceneNodeManager().createSceneNode("resources");		
		m_text = new TextVisual("Stone: " + m_resources.get(ResourceEntity.TYPE_STONE)  + " Copper: " 
				+ m_resources.get(ResourceEntity.TYPE_COPPER) + " Gold: " + m_resources.get(ResourceEntity.TYPE_GOLD));
		node.setVisual(m_text);
		node.transform(height - 100, 20, 0);
	}
	
	public int getCountForType(int _type)
	{
		return m_resources.get(_type);
	}
	
	public void increaseCountforType(int _type)
	{
		m_resources.set(_type, m_resources.get(_type)+1);
		
		m_text.setText("Stone: " + m_resources.get(ResourceEntity.TYPE_STONE) + "Copper: " 
				+ m_resources.get(ResourceEntity.TYPE_COPPER) + "Gold: " + m_resources.get(ResourceEntity.TYPE_GOLD));
	}
	
	public void increaseCountforTypeWithValue(int _type, int value)
	{
		m_resources.set(_type, m_resources.get(_type)+value);
	}
}
